package com.huidatech.mpgdemo.config;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @Description: MP配置
 * @Author: Wangzz
 * @Version: 1.0.0
 * @CreateDate: Created in 2021/10/17 13:24
 * @UpdateDate: [dateFormat:YYYY-MM-DD][modifier][description]
 */

@Configuration // 配置类
@MapperScan("com.huidatech.mpgdemo.mapper")
@EnableTransactionManagement
public class MyBatisPlusConfig {

    // 注册乐观锁插件
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor(){
        return new OptimisticLockerInterceptor();
    }

    // MP分页插件
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }


}
